home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / filesyst / ncpfs / mars_dos.000 / mars_dos / netpc / ncpcall.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-14  |  7.0 KB  |  286 lines

  1. /* ncpcall.c 14-Mar-96 */
  2.  
  3. /****************************************************************
  4.  * (C)opyright (C) 1993,1996  Martin Stover, Marburg, Germany   *
  5.  ****************************************************************/
  6.  
  7. #include "net.h"
  8.  
  9. /* ----------------  0x16 ----------------------------------- */
  10. int ncp_16_02(int dirhandle,
  11.               uint8  *path,
  12.               int    *sub_dir,
  13.               uint8  *resultpath,
  14.               uint32 *creattime,
  15.               uint32 *owner_id)
  16.  
  17. /* returns max. rights or -1 if failed */
  18. {
  19.   struct {
  20.     uint16  len;
  21.     uint8   func;
  22.     uint8   dirhandle;
  23.     uint8   sub_dir[2];
  24.     uint8   pathlen;
  25.     uint8   path[256];
  26.   } req;
  27.   struct {
  28.    uint16 len;
  29.    uint8  sub_dir_name[16];
  30.    uint8  create_date_time[4];
  31.    uint8  owner_id[4];       /* HI LOW */
  32.    uint8  max_right_mask;
  33.    uint8  reserved;          /* Reserved by Novell */
  34.    uint8  sub_dir_nmbr[2];   /* HI LOW */
  35.   } repl = { sizeof(repl) - sizeof(uint16) };
  36.   req.func      = 0x02;
  37.   U16_TO_BE16((sub_dir) ? *sub_dir : 1, req.sub_dir);
  38.   req.dirhandle = (uint8) dirhandle;
  39.   req.pathlen   = (uint8) ((path) ? strlen(path) : 0);
  40.   req.len       = 5 + req.pathlen;
  41.   strmaxcpy(req.path, path, req.pathlen);
  42.   neterrno      = Net_Call(0xE200, &req, &repl);
  43.   if (neterrno)   return(-1);
  44.   if (resultpath) strmaxcpy(resultpath, repl.sub_dir_name, 16);
  45.   if (sub_dir)    *sub_dir   = GET_BE16(repl.sub_dir_nmbr);
  46.   if (creattime)  *creattime = GET_BE32(repl.create_date_time);
  47.   if (owner_id)   *owner_id  = GET_BE32(repl.owner_id);
  48.   return((int) repl.max_right_mask);
  49. }
  50.  
  51. /* ----------------  0x17 ----------------------------------- */
  52. int ncp_17_02(int module, int debuglevel)
  53. /* debuglevel fuer module setzen */
  54. {
  55.   struct {
  56.     uint16  len;
  57.     uint8   func;
  58.     uint8   module;
  59.     uint8   debug;
  60.   } req = { sizeof(req) - sizeof(uint16) };
  61.   struct {
  62.    uint16   len;
  63.    uint8    olddebug;
  64.   } repl     = { sizeof(repl) - sizeof(uint16) };
  65.   req.func   = 0x2;
  66.   req.module = (uint8) module;
  67.   req.debug  = (uint8) debuglevel;
  68.   neterrno   = Net_Call(0xE300, &req, &repl);
  69.   if (neterrno) return(-1);
  70.   return((int) repl.olddebug);
  71. }
  72.  
  73. int ncp_17_14(uint8 *objname, uint16 objtyp, uint8 *password)
  74. /* login unencreypted */
  75. {
  76.   struct {
  77.     uint16  len;
  78.     uint8   func;
  79.     uint8   typ[2];
  80.     uint8   namlen;
  81.     uint8   buff[48+1+128];
  82.   } req;
  83.   struct {
  84.    uint16   len;
  85.   } repl= { 0 };
  86.   uint8 *p=req.buff;
  87.   req.func     = 0x14;
  88.   U16_TO_BE16(objtyp, req.typ);
  89.   req.namlen = min(47, strlen(objname));
  90.   memcpy(p,   objname, req.namlen);
  91.   p       += req.namlen;
  92.   *p = (uint8) min(128, strlen(password));
  93.   req.len      = 4 + req.namlen + 1 + *p;
  94.   memcpy(p+1, password, (int) *p);
  95.   neterrno     = Net_Call(0xE300, &req, &repl);
  96.   if (neterrno) return(-1);
  97.   return(0);
  98. }
  99.  
  100. int ncp_17_17(uint8 *key)
  101. /* get crypt key */
  102. {
  103.   struct {
  104.     uint16  len;
  105.     uint8   func;
  106.   } req;
  107.   struct {
  108.    uint16   len;
  109.    uint8    key[8];
  110.   } repl;
  111.   req.len      = 1;
  112.   req.func     = 0x17;
  113.   repl.len     = 8;
  114.   neterrno     = Net_Call(0xE300, &req, &repl);
  115.   if (neterrno) return(-1);
  116.   else {
  117.     memcpy(key, repl.key, 8);
  118.     return(0);
  119.   }
  120. }
  121.  
  122. int ncp_17_18(uint8 *cryptkey, uint8 *objname, uint16 objtyp)
  123. /* keyed login */
  124. {
  125.   struct {
  126.     uint16  len;
  127.     uint8   func;
  128.     uint8   key[8];
  129.     uint8   typ[2];
  130.     uint8   namlen;
  131.     uint8   name[48];
  132.   } req;
  133.   struct {
  134.    uint16   len;
  135.   } repl={ 0 };
  136.   req.len      = sizeof(req) - sizeof(uint16);
  137.   req.func     = 0x18;
  138.   U16_TO_BE16(objtyp, req.typ);
  139.   req.namlen   = min(sizeof(req.name), strlen(objname));
  140.   memcpy(req.key,  cryptkey, 8);
  141.   memcpy(req.name, objname, (int) req.namlen);
  142.   neterrno     = Net_Call(0xE300, &req, &repl);
  143.   if (neterrno) return(-1);
  144.   return(0);
  145. }
  146.  
  147. uint32 ncp_17_35(uint8 *objname, uint16 objtyp)
  148. /* get bindery object id */
  149. {
  150.   struct {
  151.     uint16  len;
  152.     uint8   func;
  153.     uint8   typ[2];
  154.     uint8   namlen;
  155.     uint8   name[48];
  156.   } req;
  157.   struct {
  158.    uint16   len;
  159.    uint8    object_id[4];
  160.    uint8    object_type[2];
  161.    uint8    object_name[48];
  162.   } repl;
  163.   req.len      = sizeof(req)  - sizeof(uint16);
  164.   repl.len     = sizeof(repl) - sizeof(uint16);
  165.   req.func     = 0x35;
  166.   U16_TO_BE16(objtyp, req.typ);
  167.   req.namlen   = min(sizeof(req.name), strlen(objname));
  168.   memcpy(req.name, objname, (int) req.namlen);
  169.   neterrno     = Net_Call(0xE300, &req, &repl);
  170.   if (neterrno) return(0L);
  171.   strmaxcpy(objname, repl.object_name, 47);
  172.   return(GET_BE32(repl.object_id));
  173. }
  174.  
  175. int ncp_17_36(uint32 obj_id, uint8 *objname, uint16 *objtyp)
  176. /* get bindery object name */
  177. {
  178.   struct {
  179.     uint16  len;
  180.     uint8   func;
  181.     uint8   id[4];
  182.   } req;
  183.   struct {
  184.    uint16   len;
  185.    uint8    object_id[4];
  186.    uint8    object_type[2];
  187.    uint8    object_name[48];
  188.   } repl;
  189.   req.len      = sizeof(req)  - sizeof(uint16);
  190.   repl.len     = sizeof(repl) - sizeof(uint16);
  191.   req.func     = 0x36;
  192.   U32_TO_BE32(obj_id, req.id);
  193.   neterrno     = Net_Call(0xE300, &req, &repl);
  194.   if (neterrno) return(-1);
  195.   if (objname) strmaxcpy(objname, repl.object_name, 47);
  196.   if (objtyp)  *objtyp = GET_BE16(repl.object_type);
  197.   return(0);
  198. }
  199.  
  200.  
  201. int ncp_17_40(uint8 *objname, uint16 objtyp,
  202.                                uint8 *password, uint8 *newpassword)
  203. /* change password unencreypted */
  204. {
  205.   struct {
  206.     uint16  len;
  207.     uint8   func;
  208.     uint8   typ[2];
  209.     uint8   namlen;
  210.     uint8   buff[48+1+128+1+128];
  211.   } req;
  212.   struct {
  213.    uint16   len;
  214.   } repl = { 0 };
  215.   uint8 *p=req.buff;
  216.   req.func     = 0x40;
  217.   U16_TO_BE16(objtyp, req.typ);
  218.   req.namlen = min(47, strlen(objname));
  219.   memcpy(p,   objname, req.namlen);
  220.   p       += req.namlen;
  221.   *p = (uint8) min(128, strlen(password));
  222.   req.len      = 4 + req.namlen + 1 + *p;
  223.   memcpy(p+1, password, (int) *p);
  224.   p            += (1 +  *p);
  225.   *p = (uint8) min(128, strlen(newpassword));
  226.   req.len      += (1 + *p);
  227.   memcpy(p+1, newpassword, (int) *p);
  228.   neterrno     = Net_Call(0xE300, &req, &repl);
  229.   if (neterrno) return(-1);
  230.   return(0);
  231. }
  232.  
  233. int ncp_14_46(uint32 *obj_id)
  234. /* get bindery access level & actual ID */
  235. {
  236.   struct {
  237.     uint16  len;
  238.     uint8   func;
  239.   } req;
  240.   struct {
  241.    uint16   len;
  242.    uint8    access;
  243.    uint8    id[4];
  244.   } repl;
  245.   req.len      = 1;
  246.   req.func     = 0x46;
  247.   repl.len     = 5;
  248.   neterrno     = Net_Call(0xE300, &req, &repl);
  249.   if (neterrno) return(-1);
  250.   else {
  251.     if (obj_id) *obj_id = GET_BE32(repl.id);
  252.     return(repl.access);
  253.   }
  254. }
  255.  
  256.  
  257. int ncp_17_4b(uint8 *cryptkey, uint8 *objname, uint16 objtyp,
  258.                    int passwx, uint8 *newpassword)
  259. /* keyed change password */
  260. {
  261.   struct {
  262.     uint16  len;
  263.     uint8   func;
  264.     uint8   key[8];
  265.     uint8   typ[2];
  266.     uint8   namlen;
  267.     uint8   buff[48+1+16];
  268.   } req;
  269.   struct {
  270.    uint16   len;
  271.   } repl = { 0 };
  272.   uint8 *p     = req.buff;
  273.   req.func     = 0x4b;
  274.   memcpy(req.key,  cryptkey, 8);
  275.   U16_TO_BE16(objtyp, req.typ);
  276.   req.namlen   = (uint8) min(48, strlen(objname));
  277.   req.len      = 12 + req.namlen + 1 + 16;
  278.   memcpy(p, objname, (int) req.namlen);
  279.   p   += req.namlen;
  280.   *p++ = (uint8) passwx;
  281.   memcpy(p, newpassword, 16);
  282.   neterrno     = Net_Call(0xE300, &req, &repl);
  283.   if (neterrno) return(-1);
  284.   return(0);
  285. }
  286.